package ua.kpi.ipsa.expert.api.net;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


/**
 * 
 * @author doctorpro
 *
 */
public class UserActionRetranslator implements UserListener {
	
	private List<UserListener> list = new ArrayList<UserListener>();
	
	public void removeListener(UserListener l) {
		list.remove(l);
	}
	
	public void addListener(UserListener l) {
		list.add(l);
	}

	@Override
	public void userLoggedIn(String userLogin) {
		for (Iterator<UserListener> i = list.iterator(); i.hasNext();) {
			i.next().userLoggedIn(userLogin);
		}
	}

	@Override
	public void userLoggedOut(String userLogin) {
		for (Iterator<UserListener> i = list.iterator(); i.hasNext();) {
			i.next().userLoggedOut(userLogin);
		}
	}

	@Override
	public void userAction(String login, String methodName, String marker,
			Map<String, String> userArguments) {
		for (Iterator<UserListener> i = list.iterator(); i.hasNext();) {
			i.next().userAction(login, methodName, marker, userArguments);
		}
	}

}
